# Maintainer: David Runge <dvzrv@archlinux.org>
# Contributor: Eric Bélanger <eric@archlinux.org>

pkgname=portmidi
pkgver=236
pkgrel=1
pkgdesc="Cross platform library for interfacing with OS MIDI I/O APIs"
arch=('x86_64')
url="https://github.com/mixxxdj/portmidi"
license=('MIT')
depends=('glibc')
makedepends=('alsa-lib' 'cmake')
provides=('libportmidi.so' 'libporttime.so')
source=("${pkgname}-${pkgver}.tar.gz::https://github.com/mixxxdj/portmidi/archive/refs/tags/${pkgver}.tar.gz")
sha512sums=('901729440c4b8c654ab17c4c4f1e3986813bf1e4ad1a874f46e7b1ee0c9ef4ee9f1ecfdf71012fb56b055a6185194dd22c520ae87b9f2259c18af5d189ca57da')
b2sums=('618c3778b8b2170a145ec956cd4721e731cc135d0192e4b1c35b2c93b6b0f0e74085d044beafe2095b3d8e02e1776f442ae174d342c3f391d04a2aab378b547a')

build() {
  cd "${pkgname}-${pkgver}"
  cmake -DCMAKE_INSTALL_PREFIX=/usr \
        -DCMAKE_BUILD_TYPE='None' \
        -DBUILD_TESTING=ON \
        -Wno-dev \
        -B build \
        -S .
  make VERBOSE=1 -C build
}

check() {
  cd "${pkgname}-${pkgver}"
  make VERBOSE=1 test -C build
}

package() {
  depends+=('libasound.so')

  cd "${pkgname}-${pkgver}"
  make DESTDIR="${pkgdir}" install -C build
  install -vDm 644 license.txt -t "${pkgdir}/usr/share/licenses/${pkgname}"
  install -vDm 644 {CHANGELOG,README}.txt \
    -t "${pkgdir}/usr/share/doc/${pkgname}"
}
